<template>
    <div class="Transfers" v-loading="loading" element-loading-text="拼命加载中">
        <div class="Transfers-type">
            <div>
                <div class="star" style="width: 100px">申请类型</div>
                <el-select disabled size="mini" v-model="groups" placeholder="请选择">
                    <el-option
                        v-for="item in options"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                    >
                    </el-option>
                </el-select>
            </div>
            <div v-if="groups == 1 || groups == 2" style="margin-top: 10px">
                <div class="star" style="width: 100px">申请事由</div>
                <el-input
                    style="width: 500px"
                    v-model="reason"
                    placeholder="请输入申请事由"
                    size="mini"
                    type="textarea"
                    clearable
                >
                </el-input>
            </div>
        </div>
        <div class="Transfers-plan">
            <div class="line">申请计划</div>
            <div class="Transfers-list">
                <div class="Transfers-list-module">
                    <div class="Transfers-list-module-search">
                        <el-input
                            v-model="number"
                            style="width: 400px"
                            placeholder="请输入款号/款名/SKU"
                            size="mini"
                            @keyup.enter.native="onSearch"
                            clearable
                        >
                            <el-button
                                slot="append"
                                icon="el-icon-search"
                                @click="onSearch"
                            ></el-button>
                        </el-input>
                        <el-upload
                            action="https://ssy.13yu.com/index.php/Admin/Excel/allocationExcel"
                            :headers="headers"
                            :on-success="handleSuccess"
                            :data="{ groups }"
                        >
                            <el-button size="mini" style="margin: 0 20px" type="primary"
                            >批量导入</el-button
                            >
                        </el-upload>
                        <div
                            class="pointer"
                            style="width: 120px; display: flex; align-items: center"
                            @click="onDownloadexcel"
                        >
                            <el-image
                                style="width: 20px; height: 20px; margin-right: 5px"
                                :src="excel"
                                fit="contain"
                            ></el-image>
                            <span style="border-bottom: 1px solid #333">下载示例</span>
                        </div>
                    </div>
                    <div class="Transfers-list-module-content myscroll">
                        <el-table
                            size="mini"
                            :data="tableData"
                            height="400"
                            style="width: 100%"
                            @selection-change="handleSelectionChange"
                        >
                            <el-table-column type="selection" width="55"> </el-table-column>
                            <el-table-column prop="img" label="图片" width="80">
                                <template slot-scope="{ row }">
                                    <el-image
                                        style="width: 50px; height: 50px"
                                        :src="row.img"
                                        fit="contain"
                                        :preview-src-list="[row.img]"
                                    ></el-image>
                                </template>
                            </el-table-column>
                            <el-table-column prop="product_name" label="款名">
                            </el-table-column>
                            <el-table-column prop="sku_code" label="SKU"> </el-table-column>
                            <el-table-column prop="use_num" label="可销数">
                                <template slot-scope="{ row }">
                                    {{ row.use_num || 0 }}
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </div>
                <div style="margin: 0 20px">
                    <el-button
                        type="primary"
                        :disabled="!multipleSelection.length"
                        @click="onAdd"
                    >加入申请计划<i class="el-icon-arrow-right el-icon--right"></i
                    ></el-button>
                </div>
                <div class="Transfers-list-module">
                    <div class="Transfers-list-module-search">申请计划列表</div>
                    <div class="Transfers-list-module-content myscroll">
                        <el-table
                            size="mini"
                            :data="TableDataSelect"
                            height="400"
                            style="width: 100%"
                        >
                            <el-table-column prop="img" label="图片" width="80">
                                <template slot-scope="{ row }">
                                    <el-image
                                        style="width: 50px; height: 50px"
                                        :src="row.img"
                                        fit="contain"
                                        :preview-src-list="[row.img]"
                                    ></el-image>
                                </template>
                            </el-table-column>
                            <el-table-column prop="product_name" label="款名">
                            </el-table-column>
                            <el-table-column prop="sku_code" label="SKU" width="160">
                            </el-table-column>
                            <el-table-column prop="use_num" label="可销数">
                                <template slot-scope="{ row }">
                                    {{ row.use_num || 0 }}
                                </template>
                            </el-table-column>
                            <el-table-column prop="num" label="申请数量">
                                <template slot-scope="{ row, $index }">
                                    <el-input
                                        type="number"
                                        v-model="row.num"
                                        placeholder="0"
                                        size="mini"
                                        @input="onInput($event, $index)"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="操作" align="center">
                                <template slot-scope="{ $index }">
                                    <el-button
                                        type="text"
                                        size="default"
                                        style="color: red"
                                        @click="onDelete($index)"
                                    >删除</el-button
                                    >
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </div>
            </div>
            <el-image
                style="width: 1390px; margin: 10px 0"
                :src="step"
                fit="contain"
            ></el-image>
            <div class="flexbz">
                <div style="width: 695px">
                    <div style="margin-top: 20px">
                        <div class="line" style="font-weight: 600; font-size: 14px">
                            邮寄信息
                        </div>
                        <div class="info">
                            <div>
                                <div class="star">联系人</div>
                                <div>
                                    <el-input
                                        v-model="wp_user"
                                        :onkeyup="(wp_user = wp_user.replace(/[ ]/g, ''))"
                                        placeholder="请输入联系人"
                                        size="mini"
                                        clearable
                                    ></el-input>
                                </div>
                            </div>
                            <div>
                                <div class="star">联系电话</div>
                                <div>
                                    <el-input
                                        v-model="wp_phone"
                                        :onkeyup="(wp_phone = wp_phone.replace(/[ ]/g, ''))"
                                        placeholder="请输入联系电话"
                                        size="mini"
                                        type="number"
                                        clearable
                                    ></el-input>
                                </div>
                            </div>
                            <div>
                                <div class="star">运输方式</div>
                                <div>
                                    <el-select
                                        size="mini"
                                        v-model="Couriertype"
                                        placeholder="请选择"
                                        @change="changeselectCouriertype"
                                    >
                                        <el-option
                                            ref="mySelected"
                                            v-for="(item, index) in optionCourier"
                                            :key="index"
                                            :label="item.value"
                                            :value="item.value"
                                        >
                                        </el-option>
                                    </el-select>
                                </div>
                            </div>
                        </div>
                        <div class="info" v-if="Couriertype == '快递'">
                            <div v-if="Couriertype == '快递'">
                                <div class="star">选择快递</div>
                                <div>
                                    <el-select
                                        @change="handleChangeCourier"
                                        size="mini"
                                        v-model="logistics_company_code"
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            v-for="item in Courier"
                                            :key="item.logistics_company_name"
                                            :label="item.logistics_company_name"
                                            :value="item.logistics_company_code"
                                        >
                                        </el-option>
                                    </el-select>
                                </div>
                            </div>
                        </div>
                        <div class="info" v-if="Couriertype == '快递'">
                            <div>
                                <div class="star">详细地址</div>
                                <div>
                                    <el-cascader
                                        ref="cascaderlabel"
                                        style="width: 400px"
                                        size="mini"
                                        :options="address"
                                        v-model="selectedOptions"
                                        slot="prepend"
                                        placeholder="请选择省市区"
                                        @change="handleChange"
                                    >
                                    </el-cascader>
                                    <el-input
                                        v-model="wp_address"
                                        placeholder="请输入详细地址"
                                        size="mini"
                                        clearable
                                    ></el-input>
                                </div>
                            </div>
                        </div>
                        <div
                            v-if="Couriertype == '特别紧急-闪送、达达'"
                            style="color: #67c23a; margin-top: 5px"
                        >
                            取货地址：{{ ssaddress.sha_receive }}
                            {{ ssaddress.sha_receive_tel }} {{ ssaddress.sha_place }}
                        </div>
                        <div class="info">
                            <div>
                                <div class="star">发货方式</div>
                                <div>
                                    <el-select
                                        size="mini"
                                        v-model="send_type"
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            ref="mySelected"
                                            v-for="(item, index) in optionShip"
                                            :key="index"
                                            :label="item.label"
                                            :value="item.value"
                                        >
                                        </el-option>
                                    </el-select>
                                </div>
                            </div>
                            <div v-if="send_type == 1">
                                <div class="star">计划发货日期</div>
                                <div>
                                    <el-date-picker
                                        :picker-options="pickerOptions"
                                        size="mini"
                                        v-model="date"
                                        value-format="yyyy-MM-dd"
                                        type="date"
                                        placeholder="选择日期"
                                    >
                                    </el-date-picker>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="info">
                        <div>
                            <div>备注信息</div>
                            <div>
                                <el-input
                                    style="width: 400px"
                                    v-model="remark"
                                    placeholder="请填写备注信息"
                                    size="mini"
                                    type="textarea"
                                    clearable
                                ></el-input>
                            </div>
                        </div>
                    </div>
                    <div
                        style="
              margin: 20px 80px 0 0;
              display: flex;
              flex-direction: row-reverse;
              align-items: center;
            "
                    >
                        <!-- <el-button
                    v-if="Couriertype == '快递'"
                    type="primary"
                    size="small"
                    :disabled="
                      !groups ||
                      !TableDataSelect.length ||
                      !wp_user ||
                      !wp_phone ||
                      !wp_address ||
                      !wp_province ||
                      !wp_city ||
                      !wp_area ||
                      !transport_type ||
                      !logistics_company_code ||
                      !((send_type == 1 && date) || send_type === '0')
                    "
                    @click="onSubmit"
                    >立即发起审批</el-button
                  >
                  <el-button
                    v-else
                    type="primary"
                    size="small"
                    :disabled="
                      !groups ||
                      !TableDataSelect.length ||
                      !wp_user ||
                      !wp_phone ||
                      !((send_type == 1 && date) || send_type === '0')
                    "
                    @click="onSubmit"
                    >立即发起审批</el-button
                  > -->

                        <el-button
                            v-if="Couriertype == '快递'"
                            type="primary"
                            size="small"
                            :disabled="
                !reason ||
                !groups ||
                !TableDataSelect.length ||
                !wp_user ||
                !wp_phone ||
                !wp_address ||
                !wp_province ||
                !wp_city ||
                //!wp_area ||
                !transport_type ||
                !logistics_company_code ||
                !((send_type == 1 && date) || send_type === '0')
              "
                            @click="onSubmitJX"
                        >1> 提交数据</el-button
                        >
                        <el-button
                            v-else
                            type="primary"
                            size="small"
                            :disabled="
                !reason ||
                !groups ||
                !TableDataSelect.length ||
                !wp_user ||
                !wp_phone ||
                !((send_type == 1 && date) || send_type === '0')
              "
                            @click="onSubmitJX"
                        >1> 提交数据</el-button
                        >
                        <span
                            style="
                color: red;
                font-size: 14px;
                font-weight: 600;
                margin: 0 10px;
              "
                        >
              **温馨提示，提交后别忘记点击右侧发起审批
            </span>
                    </div>
                </div>
                <div style="width: 695px">
                    <el-table
                        :data="tableDataSP"
                        border
                        style="width: 100%"
                        size="mini"
                        height="266"
                        @selection-change="handleSelectionChangeSP"
                        :header-cell-style="{ background: '#F3F4F7', color: '#555' }"
                    >
                        <el-table-column type="selection" width="55"> </el-table-column>

                        <el-table-column prop="groups" label="类型" width="55">
                            <template slot-scope="{ row }">
                                {{ row.groups | groupsTitle }}
                            </template>
                        </el-table-column>
                        <el-table-column prop="wp_user" label="收件人" width="120">
                        </el-table-column>
                        <el-table-column prop="type_no" label="款号">
                            <template slot-scope="{ row }">
                                {{ row.type_no | arrString }}
                            </template>
                        </el-table-column>
                        <el-table-column prop="jh_jc_num" label="计划申请数量" width="120">
                        </el-table-column>
                        <el-table-column prop="date" label="计划发货日期">
                            <template slot-scope="{ row }">
                                {{ row.date || "立即发货" }}
                            </template>
                        </el-table-column>
                    </el-table>
                    <div style="margin-top: 20px">
                        <el-button
                            size="small"
                            :disabled="!multipleSelectionSP.length"
                            @click="postAdminOmsSetAllocation_batch"
                        >
                            2> 批量发起审批</el-button
                        >
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import {
    postAdminOmsGetAllocationType,
    postAdminOmsSetAllocation,
    postAdminOmsgetlogisticsCompanyCode,
    postAdminOmsSetAllocation_open,
    postAdminOmsgetAllocationtjllist,
    postAdminOmsSetAllocation_batch,
    postAdminOmsgetAllocationExcel,
    postAdminOmsgetWarehouseaddress,
} from "@/api";
import { getStore } from "@/utils/localStorage.js";
import step from "@/assets/images/step.png";
import excel from "@/assets/images/excel.png";
import { regionData } from "element-china-area-data";
export default {
    filters: {
        arrString(value) {
            let string = "";
            for (let index = 0; index < value.length; index++) {
                if (index != 0) {
                    string = string + "," + value[index].type_no;
                } else {
                    string = value[index].type_no;
                }
            }
            return string;
        },
        groupsTitle(e) {
            if (e == 1) return "赠送";
            if (e == 2) return "借出";
            if (e == 3) return "归还";
            return e;
        },
        statusTitle(e) {
            if (e == 0) return "审核中";
            if (e == 1) return "已通过";
            if (e == 2) return "已拒绝";
            if (e == 3) return "已撤销";
            return e;
        },
        is_returnTitle(e) {
            if (e == 0) return "未归还";
            if (e == 1) return "部分归还";
            if (e == 2) return "全部归还";
            return e;
        },
    },
    data() {
        return {
            excel,
            step,
            headers: {},
            pickerOptions: {
                disabledDate(time) {
                    //Date.now()是javascript中的内置函数，它返回自1970年1月1日00:00:00 UTC以来经过的毫秒数。
                    return time.getTime() < Date.now();
                },
            },
            number: "",
            loading: false,
            address: regionData,
            ssaddress: "",
            Couriertype: "",
            selectedOptions: [],
            Courier: [],
            optionCourier: [
                {
                    value: "快递",
                    label: "快递",
                },
                {
                    value: "上门取货",
                    label: "上门取货",
                },
                {
                    value: "无需快递",
                    label: "无需快递",
                },
                {
                    value: "特别紧急-闪送、达达",
                    label: "特别紧急-闪送、达达",
                },
            ],
            optionShip: [
                {
                    value: "0",
                    label: "立即发货",
                },
                {
                    value: "1",
                    label: "计划发货",
                },
            ],
            options: [
                {
                    value: "1",
                    label: "赠送",
                },
                {
                    value: "2",
                    label: "借出",
                },
                // {
                //   value: "3",
                //   label: "归还",
                // },
            ],
            groups: "",
            wp_phone: "",
            wp_address: "",
            wp_user: "",
            wp_province: "",
            wp_city: "",
            wp_area: "",
            remark: "",
            reason: "",
            transport_type: "",
            logistics_company_code: "",
            send_type: "0",
            date: "",
            tableData: [],
            tableDataSP: [],
            multipleSelection: [],
            multipleSelectionSP: [],
            TableDataSelect: [],
        };
    },
    activated() {
        this.groups = this.$route.query.groups + "";
        this.postAdminOmsgetlogisticsCompanyCode();
        this.postAdminOmsgetAllocationtjllist();
        this.postAdminOmsgetWarehouseaddress();
        this.headers = {
            token: getStore("userinfo").token,
        };
    },
    mounted(){
        console.log(this.address)
    },
    methods: {
        onDownloadexcel() {
            window.open(
                "https://ssy.13yu.com/Public/excel/moban/%E5%80%9F%E8%B5%A0%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx"
            );
        },
        async postAdminOmsgetWarehouseaddress() {
            let res = await postAdminOmsgetWarehouseaddress();
            this.ssaddress = res.data;
        },
        async postAdminOmsSetAllocation_batch() {
            let that = this;
            let { multipleSelectionSP } = this;
            console.log("multipleSelectionSP", multipleSelectionSP);
            let allocation_number = [];
            for (let index = 0; index < multipleSelectionSP.length; index++) {
                allocation_number.push(multipleSelectionSP[index].allocation_number);
            }
            this.$confirm("确定发起审批?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(async () => {
                    let obj = {
                        allocation_number,
                    };
                    try {
                        await postAdminOmsSetAllocation_batch(obj);
                        this.$message.success("发起成功");
                        await that.postAdminOmsgetAllocationtjllist(that.form);
                    } catch (error) {}
                })
                .catch(() => {});
        },
        handleSelectionChangeSP(val) {
            console.log("val", val);
            this.multipleSelectionSP = val;
        },
        async postAdminOmsgetAllocationtjllist() {
            let form = {
                status: -1,
                page: 1,
                size: 10000,
                groups: 2
            };
            let res = await postAdminOmsgetAllocationtjllist(form);
            let tableDataSP = res.data;
            this.tableDataSP = tableDataSP;
        },
        changeselectCouriertype(e) {
            console.log("e", e);
            if (e != "快递") {
                this.remark = e;
            } else {
                this.remark = "";
            }
        },
        async postAdminOmsgetlogisticsCompanyCode() {
            let res = await postAdminOmsgetlogisticsCompanyCode();
            this.Courier = res.data;
        },
        handleChangeCourier(val) {
            this.transport_type = this.Courier.find(
                (item) => item.logistics_company_code == val
            ).logistics_company_name;
        },
        // 省市区
        handleChange(e) {
            if (e.length) {
                let label = this.$refs.cascaderlabel.getCheckedNodes();
                let arr = label[0].pathLabels;
                this.wp_province = arr[0];
                this.wp_city = arr[1];
                this.wp_area = arr[2];
            } else {
                this.wp_province = "";
                this.wp_city = "";
                this.wp_area = "";
            }
        },
        onInput(e, index) {
            let { TableDataSelect } = this;
            let tmpObj = TableDataSelect[index];
            if (Number(e)) {
                tmpObj.num = e;
            } else {
                tmpObj.num = 1;
            }
            this.$set(this.TableDataSelect, index, tmpObj);
        },
        onSearch() {
            let { number } = this;
            let obj = {
                number,
            };
            if (!number) {
                this.$message.warning("提示：请输入款号/款名/SKU")
                return false;
            }
            this.loading = true;
            try {
                postAdminOmsGetAllocationType(obj).then((res) =>{
                    this.loading = false;
                    if(res.code === 0){
                        this.tableData = res.data;
                        this.multipleSelection = [];

                    }else{
                        this.$message.error(res.msg);
                    }
                });
            } catch (error) {
                this.loading = false;
            }
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },
        onAdd() {
            let { multipleSelection, TableDataSelect } = this;
            multipleSelection = multipleSelection.map((e) => {
                e.num = 1;
                return e;
            });
            let arr = [];
            for (let index = 0; index < multipleSelection.length; index++) {
                let is = TableDataSelect.some((e) => {
                    return e.sku_code == multipleSelection[index].sku_code;
                });
                if (!is) {
                    arr.push(multipleSelection[index]);
                }
            }
            TableDataSelect.push(...arr);
            this.TableDataSelect = TableDataSelect;
        },
        onDelete(e) {
            let { TableDataSelect } = this;
            this.$confirm("确定删除", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    TableDataSelect.splice(e, 1);
                    this.TableDataSelect = TableDataSelect;
                    this.$message({
                        type: "success",
                        message: "删除成功!",
                    });
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消删除",
                    });
                });
        },
        async onSubmit() {
            this.loading = true;
            let {
                TableDataSelect,
                groups,
                wp_user,
                wp_phone,
                wp_address,
                wp_province,
                wp_city,
                wp_area,
                remark,
                reason,
                transport_type,
                logistics_company_code,
                Couriertype,
                date,
                send_type,
            } = this;
            if (!/^1(3|4|5|6|7|8|9)\d{9}$/.test(wp_phone)) {
                this.$message.warning("手机号码有误，请重填");
                this.loading = false;
                return false;
            }
            if (Couriertype != "快递") {
                wp_address = "";
                wp_province = "";
                wp_city = "";
                wp_area = "";
            }
            if (send_type == 0) {
                date = "";
            }
            let is = TableDataSelect.some((e) => {
                return Number(e.num) > Number(e.use_num) || !e.use_num;
            });
            let arr = [];
            for (let index = 0; index < TableDataSelect.length; index++) {
                let obj = {
                    id: TableDataSelect[index].id,
                    sku_code: TableDataSelect[index].sku_code,
                    num: TableDataSelect[index].num,
                };
                arr.push(obj);
            }
            remark = remark.replace(/\r|\n/gi, "");
            reason = reason.replace(/\r|\n/gi, "");
            if (send_type == 0) {
                remark = remark + " 立即发货";
            } else {
                remark = remark + " 计划发货日期:" + date;
            }

            let obj = {
                wp_user,
                wp_phone,
                wp_province,
                wp_city,
                wp_area,
                wp_address,
                groups,
                remark,
                reason,
                transport_type,
                logistics_company_code,
                send_type,
                date,
                arrlist: arr,
            };
            if (!is) {
                try {
                    let res = await postAdminOmsSetAllocation(obj);
                    this.$message.success("提交成功");
                    this.loading = false;
                    this.number = "";
                    this.wp_phone = "";
                    this.wp_address = "";
                    this.wp_user = "";
                    this.wp_province = "";
                    this.wp_city = "";
                    this.wp_area = "";
                    this.remark = "";
                    this.reason = "";
                    this.transport_type = "";
                    this.logistics_company_code = "";
                    this.Couriertype = "";
                    this.send_type = "";
                    this.date = "";
                    this.tableData = [];
                    this.multipleSelection = [];
                    this.TableDataSelect = [];
                    this.selectedOptions = [];
                } catch (error) {
                    this.loading = false;
                }
            } else {
                this.$confirm("申请数量不能大于可销数！", "提示", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning",
                })
                    .then(async () => {
                        try {
                            this.loading = false;
                        } catch (error) {
                            this.loading = false;
                        }
                    })
                    .catch(() => {
                        this.loading = false;
                    });
            }
        },
        async handleSuccess(response, file, fileList) {
            this.loading = true;
            let obj = {};
            if (response.code == 0) {
                obj.identification = response.data.identification;
            } else {
                this.loading = false;
                this.$message.warning(response.msg);
                return;
            }
            try {
                let res = await postAdminOmsgetAllocationExcel(obj);
                let multipleSelection = res.data;
                let { TableDataSelect } = this;
                multipleSelection = multipleSelection.map((e) => {
                    if (!e.num) {
                        e.num = 1;
                    }
                    e.sku_code = e.sku;
                    return e;
                });
                let arr = [];
                for (let index = 0; index < multipleSelection.length; index++) {
                    let is = TableDataSelect.some((e) => {
                        return e.sku_code == multipleSelection[index].sku_code;
                    });
                    if (!is) {
                        arr.push(multipleSelection[index]);
                    }
                }
                TableDataSelect.push(...arr);
                this.TableDataSelect = TableDataSelect;
                this.loading = false;
            } catch (error) {
                this.loading = true;
            }
        },
        onSubmitJX() {
            this.loading = true;
            let {
                TableDataSelect,
                groups,
                wp_user,
                wp_phone,
                wp_address,
                wp_province,
                wp_city,
                wp_area,
                remark,
                reason,
                transport_type,
                logistics_company_code,
                Couriertype,
                date,
                send_type,
            } = this;
            // if (!/^1(3|4|5|6|7|8|9)\d{9}$/.test(wp_phone)) {
            //   this.$message.warning("手机号码有误，请重填");
            //   this.loading = false;
            //   return false;
            // }
            if (Couriertype != "快递") {
                wp_address = "";
                wp_province = "";
                wp_city = "";
                wp_area = "";
            }
            if (send_type == 0) {
                date = "";
            }
            // let is = TableDataSelect.some((e) => {
            //   return Number(e.num) > Number(e.use_num) || !e.use_num;
            // });
            let arr = [];
            for (let index = 0; index < TableDataSelect.length; index++) {
                let obj = {
                    id: TableDataSelect[index].id,
                    sku_code: TableDataSelect[index].sku_code,
                    num: TableDataSelect[index].num,
                };
                arr.push(obj);
            }
            remark = remark.replace(/\r|\n/gi, "");
            reason = reason.replace(/\r|\n/gi, "");
            if (send_type == 0) {
                remark = remark + " 立即发货";
            } else {
                remark = remark + " 计划发货日期:" + date;
            }
            let obj = {
                wp_user,
                wp_phone,
                wp_province,
                wp_city,
                wp_area,
                wp_address,
                groups,
                remark,
                reason,
                transport_type,
                logistics_company_code,
                send_type,
                date,
                arrlist: arr,
            };
            try {
                postAdminOmsSetAllocation_open(obj).then((res) => {
                    this.loading = false;
                    if(res.code === 0){
                        this.$message.success("提交成功");
                        this.postAdminOmsgetAllocationtjllist();
                        this.number = "";
                        this.wp_phone = "";
                        this.wp_address = "";
                        this.wp_user = "";
                        this.wp_province = "";
                        this.wp_city = "";
                        this.wp_area = "";
                        this.remark = "";
                        this.reason = "";
                        this.transport_type = "";
                        this.logistics_company_code = "";
                        this.Couriertype = "";
                        this.send_type = "";
                        this.date = "";
                        this.tableData = [];
                        this.multipleSelection = [];
                        this.TableDataSelect = [];
                        this.selectedOptions = [];
                    }else{
                        this.$message.error(res.msg);
                    }
                });
            } catch (error) {
                this.loading = false;
            }
        },
    },
};
</script>

<style lang="scss" scoped>
.exceldata {
    width: 145px;
    border-bottom: 1px solid #ddd;
    margin-bottom: 10px;
    padding-bottom: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;

    .exceldata-one {
        display: flex;
        align-items: center;
        margin-top: 10px;
    }
}

.flexbz {
    display: flex;
    width: 1390px;
}

.info {
    display: flex;
    margin-top: 15px;

    > div {
        margin-right: 20px;

        > :nth-child(1) {
            font-size: 12px;
            margin-bottom: 10px;
        }

        > div:nth-child(2) {
            display: flex;
            align-items: center;
        }
    }
}

.myscroll {
    overflow-y: scroll;
    overflow-x: hidden;
}

.myscroll::-webkit-scrollbar {
    display: none;
}

// 隐藏滚动条
.Transfers {
    background: #fff;
    font-size: 14px;
    padding: 20px 0;

    .Transfers-type {
        padding: 10px 20px;
        // display: flex;
        // align-items: center;
        border-bottom: 1px solid #efefef;

        > div {
            display: flex;
            align-items: center;
            margin-right: 10px;
        }
    }

    .Transfers-plan {
        padding: 10px 20px;
        /deep/ .el-upload-list {
            display: none;
        }
        > div:nth-child(1) {
            font-weight: 600;
            margin-bottom: 20px;
        }

        .Transfers-list {
            display: flex;
            align-items: center;

            .Transfers-list-module {
                border: 1px solid #efefef;
                width: 600px;
                border-radius: 4px;

                .Transfers-list-module-search {
                    padding: 0 20px;
                    height: 48px;
                    display: flex;
                    align-items: center;
                    background-color: #f5f7fa;
                    font-weight: 600;
                    font-size: 12px;
                }

                .Transfers-list-module-content {
                    height: 400px;

                    /deep/ .el-table__row {
                        height: 53px;
                    }
                }
            }
        }
    }
}
</style>
